﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SYFramework
{
    public abstract class IObserver
    {

        private ISubject subject=null;

        public void SetSubject(ISubject subject)
        {
            this.subject = subject;
        }
        public abstract void Update(EventBase eventBase);
       
    }

    public class UIObserver : IObserver
    {

        public override void Update(EventBase eventBase)
        {
            UIEventBase uIEventBase =(UIEventBase)eventBase;

            //处理
            Debug.Log("UI 事件:"+ uIEventBase.Name);
        }
    }

    public class Enemy1Observer : IObserver
    {
        public override void Update(EventBase eventBase)
        {
            EnemyEventBase enemyEventBase= (EnemyEventBase)eventBase;
            if(enemyEventBase.Gold>0)
            Debug.Log("1 敌人获得金币" + enemyEventBase.Gold);
        }
    }
    public class Enemy2Observer : IObserver
    {
        public override void Update(EventBase eventBase)
        {
            EnemyEventBase enemyEventBase = (EnemyEventBase)eventBase;
            if (enemyEventBase.Gold <0)
                Debug.Log("2 敌人获得金币" + enemyEventBase.Gold);
        }
    }
}

